import { createSlice, PayloadAction } from '@reduxjs/toolkit'

export interface IState {
  count: number
  message: string
}

const initialState: IState = {
  count: 100,
  message: 'demo counter slice'
}
const counterSlice = createSlice({
  name: 'counter',
  initialState,
  reducers: {
    changeMessageAction(state, action: PayloadAction<string>) {
      state.message = action.payload
    }
  }
})

export default counterSlice.reducer
export const { changeMessageAction } = counterSlice.actions
